//package com.xyh.transaction.filter;
//
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.http.HttpMethod;
//import org.springframework.web.cors.CorsConfiguration;
//import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
//import org.springframework.web.filter.CorsFilter;
//
///**
// * 解决前后端跨域问题
// *
// * @author xiao
// * @date 2023/11/11
// */
//@Configuration
//public class CORSFilter {
//    @Bean
//    public CorsFilter corsFilter(){
//        CorsConfiguration corsConfiguration = new CorsConfiguration();
//        corsConfiguration.addAllowedHeader("*");
//        corsConfiguration.addAllowedOrigin("http://localhost:8848");
//        corsConfiguration.addAllowedOrigin("https://quick-dane-honestly.ngrok-free.app");
//        corsConfiguration.addAllowedMethod("*");
//        corsConfiguration.setAllowCredentials(true); // 允许使用凭证
//        // 允许的预检请求方法
//        corsConfiguration.addAllowedMethod(HttpMethod.OPTIONS);
//        UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
//        source.registerCorsConfiguration("/**",corsConfiguration);
//        return new CorsFilter(source);
//    }
//}